package  com.macllvm.whale.protocol;

/*
* all constant values are from open source project ipmag
*/
public class  ProtocolBase  {

    public static final int  IPMSG_VERSION = 0x001;
    public static final int  IPMSG_PORT = 2425;

    //command
    public static final int  IPMSG_NOOPERATION = 0x00000000;

    public static final int  IPMSG_BR_ENTRY = 0x00000001;
    public static final int  IPMSG_BR_EXIT = 0x00000002;
    public static final int  IPMSG_ANSENTRY = 0x00000003;
    public static final int  IPMSG_BR_ABSENCE = 0x00000004;

    public static final int  IPMSG_BR_ISGETLIST = 0x00000010;
    public static final int  IPMSG_OKGETLIST = 0x00000011;
    public static final int  IPMSG_GETLIST = 0x00000012;
    public static final int  IPMSG_ANSLIST = 0x00000013;
    public static final int  IPMSG_BR_ISGETLIST2 = 0x00000018;

    public static final int  IPMSG_SENDMSG = 0x00000020;
    public static final int  IPMSG_RECVMSG = 0x00000021;
    public static final int  IPMSG_READMSG = 0x00000030;
    public static final int  IPMSG_DELMSG = 0x00000031;
    public static final int  IPMSG_ANSREADMSG = 0x00000032;

    public static final int  IPMSG_GETINFO = 0x00000040;
    public static final int  IPMSG_SENDINFO = 0x00000041;

    public static final int  IPMSG_GETABSENCEINFO = 0x00000050;
    public static final int  IPMSG_SENDABSENCEINFO = 0x00000051;

    public static final int  IPMSG_GETFILEDATA = 0x00000060;
    public static final int  IPMSG_RELEASEFILES = 0x00000061;
    public static final int  IPMSG_GETDIRFILES = 0x00000062;

    public static final int  IPMSG_GETPUBKEY = 0x00000072;
    public static final int  IPMSG_ANSPUBKEY = 0x00000073;

    //option for all command
    public static final int  IPMSG_ABSENCEOPT = 0x00000100;
    public static final int  IPMSG_SERVEROPT = 0x00000200;
    public static final int  IPMSG_DIALUPOPT = 0x00010000;
    public static final int  IPMSG_FILEATTACHOPT = 0x00200000;
    public static final int  IPMSG_ENCRYPTOPT = 0x00400000;
    public static final int  IPMSG_UTF8OPT = 0x00800000;

    //option for send command
    public static final int  IPMSG_SENDCHECKOPT = 0x00000100;
    public static final int  IPMSG_SECRETOPT = 0x00000200;
    public static final int  IPMSG_BROADCASTOPT = 0x00000400;
    public static final int  IPMSG_MULTICASTOPT = 0x00000800;
    public static final int  IPMSG_NOPOPUPOPT = 0x00001000;
    public static final int  IPMSG_AUTORETOPT = 0x00002000;
    public static final int  IPMSG_RETRYOPT = 0x00004000;
    public static final int  IPMSG_PASSWORDOPT = 0x00008000;
    public static final int  IPMSG_NOLOGOPT = 0x00020000;
    public static final int  IPMSG_NEWMUTIOPT = 0x00040000;
    public static final int  IPMSG_NOADDLISTOPT = 0x00080000;
    public static final int  IPMSG_READCHECKOPT = 0x00100000;
    public static final int  IPMSG_SECRETEXOPT = (IPMSG_READCHECKOPT|IPMSG_SECRETOPT);

    public static final int  IPMSG_NO_REPLY_OPTS = (IPMSG_BROADCASTOPT|IPMSG_AUTORETOPT);

    //encryption flags for encrypt command
    public static final int  IPMSG_RSA_512 = 0x00000001;
    public static final int  IPMSG_RSA_1024 = 0x00000002;
    public static final int  IPMSG_RSA_2048 = 0x00000004;
    public static final int  IPMSG_RC2_40 = 0x00001000;
    public static final int  IPMSG_RC2_128 = 0x00004000;
    public static final int  IPMSG_RC2_256 = 0x00008000;
    public static final int  IPMSG_BLOWFISH_128 = 0x00020000;
    public static final int  IPMSG_BLOWFISH_256 = 0x00040000;
    public static final int  IPMSG_AES_128 = 0x00100000;
    public static final int  IPMSG_AES_192 = 0x00200000;
    public static final int  IPMSG_AES_256 = 0x00400000;
    public static final int  IPMSG_SIGN_STAMPOPT = 0x01000000;
    public static final int  IPMSG_SIGN_MD5 = 0x10000000;
    public static final int  IPMSG_SIGN_SHA1 = 0x20000000;

    // compatibilty for Win beta version
    public static final int  IPMSG_RC2_40OLD = 0x00000010;    // for beta1-4 only
    public static final int  IPMSG_RC2_128OLD = 0x00000040;    // for beta1-4 only
    public static final int  IPMSG_BLOWFISH_128OLD = 0x00000400;    // for beta1-4 only
    public static final int  IPMSG_RC2_40ALL = (IPMSG_RC2_40|IPMSG_RC2_40OLD);
    public static final int  IPMSG_RC2_128ALL = (IPMSG_RC2_128|IPMSG_RC2_128OLD);
    public static final int  IPMSG_BLOWFISH_128ALL = (IPMSG_BLOWFISH_128|IPMSG_BLOWFISH_128OLD);

    // file types for fileattach command
    public static final int  IPMSG_FILE_REGULAR = 0x00000001;
    public static final int  IPMSG_FILE_DIR = 0x00000002;
    public static final int  IPMSG_FILE_RETPARENT = 0x00000003;    // return parent directory
    public static final int  IPMSG_FILE_SYMLINK = 0x00000004;
    public static final int  IPMSG_FILE_CDEV = 0x00000005;    // for UNIX
    public static final int  IPMSG_FILE_BDEV = 0x00000006;    // for UNIX
    public static final int  IPMSG_FILE_FIFO = 0x00000007;    // for UNIX
    public static final int  IPMSG_FILE_RESFORK = 0x00000010;    // for Mac

    // file attribute options for fileattach command
    public static final int  IPMSG_FILE_RONLYOPT = 0x00000100;
    public static final int  IPMSG_FILE_HIDDENOPT = 0x00001000;
    public static final int  IPMSG_FILE_EXHIDDENOPT = 0x00002000;    // for MacOS X
    public static final int  IPMSG_FILE_ARCHIVEOPT = 0x00004000;
    public static final int  IPMSG_FILE_SYSTEMOPT = 0x00008000;

    // extend attribute types for fileattach command
    public static final int  IPMSG_FILE_UID = 0x00000001;
    public static final int  IPMSG_FILE_USERNAME = 0x00000002;    // uid by string
    public static final int  IPMSG_FILE_GID = 0x00000003;
    public static final int  IPMSG_FILE_GROUPNAME = 0x00000004;    // gid by string
    public static final int  IPMSG_FILE_PERM = 0x00000010;    // for UNIX
    public static final int  IPMSG_FILE_MAJORNO = 0x00000011;    // for UNIX devfile
    public static final int  IPMSG_FILE_MINORNO = 0x00000012;    // for UNIX devfile
    public static final int  IPMSG_FILE_CTIME  = 0x00000013;    // for UNIX
    public static final int  IPMSG_FILE_MTIME = 0x00000014;
    public static final int  IPMSG_FILE_ATIME  = 0x00000015;
    public static final int  IPMSG_FILE_CREATETIME = 0x00000016;
    public static final int  IPMSG_FILE_CREATOR = 0x00000020;    // for Mac
    public static final int  IPMSG_FILE_FILETYPE = 0x00000021;    // for Mac
    public static final int  IPMSG_FILE_FINDERINFO = 0x00000022;    // for Mac
    public static final int  IPMSG_FILE_ACL = 0x00000030;
    public static final int  IPMSG_FILE_ALIASFNAME = 0x00000040;    // alias fname
    public static final int  IPMSG_FILE_UNICODEFNAME = 0x00000041;   // UNICODE fname

    public static final String  FILELIST_SEPARATOR = "\\a";
    public static final String  HOSTLIST_SEPARATOR = "\\a";
    public static final String  HOSTLIST_DUMMY = "\b";
    public static final char  HLIST_ENTRY_SEPARATOR = ':';



    // header
    public static final String  IPTUX_VERSION = "1_iptux_1#0#0";
    public static final int  IPTUX_DEFAULT_PORT = IPMSG_PORT;

    // command
    public static final int  IPTUX_ASKSHARED = 0x000000FF;
    public static final int  IPTUX_SENDICON = 0x000000FE;
    public static final int  IPTUX_SENDSUBLAYER = 0x000000FD;
    public static final int  IPTUX_SENDSIGN = 0x000000FC;
    public static final int  IPTUX_SENDMSG = 0x000000FB;
    // option for IPTUX_SENDSUBLAYER
    public static final int  IPTUX_PHOTOPICOPT = 0x00000100;
    public static final int  IPTUX_MSGPICOPT = 0x00000200;
    // option for IPMSG_SENDMSG
    public static final int  IPTUX_SHAREDOPT = 0x80000000;
    // option for IPMSG_SENDMSG & IPTUX_ASKSHARED
    public static final int  IPTUX_PASSWDOPT = 0x40000000;
    // option for IPTUX_SENDMSG
    public static final int  IPTUX_REGULAROPT = 0x00000100;
    public static final int  IPTUX_SEGMENTOPT = 0x00000200;
    public static final int  IPTUX_GROUPOPT  = 0x00000300;
    public static final int  IPTUX_BROADCASTOPT = 0x00000400;
    // data
    public static final int  MAX_SOCKLEN = 8192;
    public static final int  MAX_UDPLEN = 8192;
    public static final int  MAX_BUFLEN = 1024;
    public static final int  MAX_PATHLEN = 1024;
    public static final int  MAX_SHAREDFILE = 10000;
    public static final int  MAX_ICONSIZE = 30;
    public static final int  MAX_PREVIEWSIZE = 150;
    public static final int  MAX_PHOTOSIZE = 300;
    public static final int  MAX_RETRYTIMES = 4;


    public static int  GET_MODE(int command) {
        return (command & 0x000000ff);
    }

    public static int  GET_OPT(int command)  {
        return (command & 0xffffff00);
    }

    public static boolean  HAS_ATTACHED(int command) {
        return (command != 0x00000000);
    }
}
